package logic;

import java.io.*;
import java.net.*;

public class NetworkHost {

	public static void main(String args[]) {

		try {
			InetAddress thisIp = InetAddress.getLocalHost();
			System.out.println(thisIp.getHostAddress().toString());
		} catch (Exception e) {
		}

		String data = "Siehste geht doch der Scheisz :D";
		int timeout = 30000;

		try {
			ServerSocket connect = new ServerSocket(4444);
			connect.setSoTimeout(timeout);
			System.out.println(connect.getInetAddress());
			System.out.println(connect.getLocalSocketAddress());
			Socket s = connect.accept();
			System.out.print("Server has connected!");
			PrintWriter out = new PrintWriter(s.getOutputStream(), true);
			System.out.print("Sending string: '" + data);
			out.print(data);
			out.close();
			s.close();
			connect.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
